package twiddles.littleprincess.dao;

import javax.persistence.EntityManager;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.jpa.JpaTemplate;
import org.springframework.transaction.annotation.Transactional;

import twiddles.littleprincess.dao.entity.Test;


public class TestDao extends JpaTemplate implements ITestDao {

	//private EntityManager entityManager;
	
	//public JpaTemplate getTemplate() {
	//	return new JpaTemplate(entityManager);
	//}
	
	@Override
	public void createTestData() {
		
		
		Test t1 = new Test();
		t1.setTestString("Test String 1");
		
		Test t2 = new Test();
		t2.setTestString("Test String 2");
		
		
		save(t1);
		save(t2);
		

	}
	

	@Transactional
	private void save(Test t) {
		//EntityTransaction trx = entityManager.getTransaction();
		//trx.begin();
		persist(t);
		//trx.commit();
	}
	
	//@Autowired
	//public void setEntityManager(EntityManager entityManager) {
	//	this.entityManager = entityManager;
	//}


}
